package hadoop.mr03;

import org.apache.hadoop.io.Writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class Food_City implements Writable {
    int comments; // 点评数
    double taste; // 口味
    double environment; // 环境
    double serve; // 服务

    public int getComments() {
        return comments;
    }

    public void setComments(int comments) {
        this.comments = comments;
    }

    public double getTaste() {
        return taste;
    }

    public void setTaste(double taste) {
        this.taste = taste;
    }

    public double getEnvironment() {
        return environment;
    }

    public void setEnvironment(double environment) {
        this.environment = environment;
    }

    public double getServe() {
        return serve;
    }

    public void setServe(double serve) {
        this.serve = serve;
    }

    public Food_City(int comments, double taste, double environment, double serve) {
        this.comments = comments;
        this.taste = taste;
        this.environment = environment;
        this.serve = serve;
    }

    public Food_City() {
    }

    @Override
    public String toString() {
        return this.comments+"\t"+this.taste+"\t"+this.environment+"\t"+this.serve;
    }

    @Override
    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeInt(comments);
        dataOutput.writeDouble(taste);
        dataOutput.writeDouble(environment);
        dataOutput.writeDouble(serve);
    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {
        this.comments = dataInput.readInt();
        this.taste = dataInput.readDouble();
        this.environment = dataInput.readDouble();
        this.serve = dataInput.readDouble();
    }
}
